package com.javacode2018.demo1;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

@Component
public class UserService1 extends UserService {

    @Autowired
    private UserService1 userService1;

    @Transactional
    @Override
    public void insert() throws Exception {
        this.userDao.insert("tom1");
        try {
            this.userDao.insert("tom2111111111111111111111");
        } catch (Exception e) {
            throw new Exception(e);
        }
        System.out.println("tom1");
    }

    @Transactional(propagation = Propagation.SUPPORTS)
    public void insert1(){
        this.userDao.insert("tom2111111111111111111111");
        System.out.println("tom2");
    }
}
